package com.epfresh.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.TextView;
import com.epfresh.R;
import com.epfresh.global.BaseActivity;
public class PayWaitActivity extends BaseActivity {
	String factSum,wallets,noPay,onLinePay;

	static final String TAG = "AboutActivity";
	private ImageView pay_wait;
	private TextView wait_second;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		initView();
		basetitle.setText("收银台");
		if (savedInstanceState != null) {
			getIntent().putExtra("factSum", savedInstanceState.getString("factSum"));
			getIntent().putExtra("wallets", savedInstanceState.getString("wallets"));
			getIntent().putExtra("noPay", savedInstanceState.getString("noPay"));
			getIntent().putExtra("onLinePay", savedInstanceState.getString("onLinePay"));
		}

		factSum = getIntent().getStringExtra("factSum");
		wallets = getIntent().getStringExtra("wallets");
		noPay = getIntent().getStringExtra("noPay");
		onLinePay = getIntent().getStringExtra("onLinePay");
		Animation operatingAnim = AnimationUtils.loadAnimation(this, R.anim.pay_wait);
		LinearInterpolator lin = new LinearInterpolator();
		operatingAnim.setInterpolator(lin);
		pay_wait.startAnimation(operatingAnim);
		wait_second.postDelayed(new Runnable() {
			@Override
			public void run() {
				wait_second.setText(4 + "");
			}
		}, 1000);
		wait_second.postDelayed(new Runnable() {
			@Override
			public void run() {
				wait_second.setText(3+"");
			} },2000 );
		wait_second.postDelayed(new Runnable() {
			@Override
			public void run() {
				wait_second.setText(2+"");
			} },3000 );
		wait_second.postDelayed(new Runnable() {
			@Override
			public void run() {
				wait_second.setText(1+"");
			} },4000 );
		pay_wait.postDelayed(new Runnable() {
			@Override
			public void run() {

				Intent success = new Intent(mContext, OrderSuccessActivity.class);
				success.putExtra("factSum", factSum);
				success.putExtra("wallets", wallets);
				success.putExtra("noPay", noPay);
				success.putExtra("onLinePay", onLinePay);
				startActivity(success);
				finish();
			} },5000 );
	}
	void initView(){
		setContentView(R.layout.activity_pay_wait);
		wait_second = (TextView)findViewById(R.id.wait_second);
		pay_wait = (ImageView)findViewById(R.id.pay_wait);
	}
	@Override
	protected void onSaveInstanceState(Bundle outState) {
		outState.putString("factSum", factSum);
		outState.putString("wallets", wallets);
		outState.putString("noPay", noPay);
		outState.putString("onLinePay", onLinePay);
		super.onSaveInstanceState(outState);
	}

}
